void reverse(char* a)
{
    int n = strlen(a), i = 0;
    for (i = 0; i < n / 2; i++) {
        int tmp = a[i];
        a[i] = a[n - i - 1];
        a[n - i - 1] = tmp;
    }
}




char* addBinary(char* a, char* b) {
    int len_a = strlen(a);
    int res = 0, i = 0;
    int len_b = strlen(b);
    int n = len_a > len_b ? len_a : len_b;
    char* ch = (char*)calloc(n + 5, 1);
    reverse(a); reverse(b);
    for (i = 0; i < n; i++) {
        int x = i < len_a ? a[i] - '0' : 0;
        int y = i < len_b ? b[i] - '0' : 0;
        ch[i] = (x + y + res) % 2 + '0';
        res = (x + y + res) / 2;
    }
    if (res > 0) {
        ch[i] = res + '0';
    }
    reverse(ch);
    return ch;
}